{extend name='comm/base' /}

{block name='header'}
{include file='comm/header'}
{/block}

{block name='slider'}
{include file='comm/slider'}
{/block}

{block name='main'}
<div class="main-content">
    <div class="main-content-inner">
        <div class="breadcrumbs ace-save-state" id="breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a href="#">物品管理</a>
                </li>
                <li class="active">物品信息管理</li>
            </ul><!-- /.breadcrumb -->
        </div>
        <div class="page-content">

            <div class="page-header">
                <h1>
                    物品
                    <small>
                        <i class="ace-icon fa fa-angle-double-right"></i>
                        新增物品信息
                    </small>
                </h1>
            </div><!-- /.page-header -->
            <div class="row">
                <div class="col-xs-12">
                    <!-- PAGE CONTENT BEGINS -->
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="classify" >物品种类</label>
                            <div class="col-sm-9">
                                <input type="text" id="classify" placeholder="物品种类" class="col-xs-10 col-sm-5" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">物品价值区间</label>
                            <div class="col-sm-9">
                                <i class="ace-icon fa fa-leaf blue"></i>
                                <input type="text" id="worth" placeholder="物品价值区间（单位：元）" class="col-xs-10 col-sm-5" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">单位重量价格</label>
                            <div class="col-sm-9">
                                <i class="ace-icon fa fa-leaf blue"></i>
                                <input type="text" id="weight_money" placeholder="单位重量价格（以公斤为单位）" class="col-xs-10 col-sm-5" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">用户状态</label>
                            <div class="col-sm-3">
                                <select class="chosen-select form-control" id="status" data-placeholder="Choose a State...">
                                    <option value="0">禁用</option>
                                    <option value="1">启用</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">备注</label>
                            <div class="col-sm-9">
                                <i class="ace-icon fa fa-leaf blue"></i>
                                <input type="text" id="remark" placeholder="备注" class="col-xs-10 col-sm-5" />
                            </div>
                        </div>

                        <div class="clearfix form-actions">
                            <div class="col-md-offset-3 col-md-9">
                                <button class="btn btn-primary" type="button" id="save_btn">
                                    保存
                                </button>
                            </div>
                        </div>

                        <div class="hr hr-24"></div>
                    </form>

                    <!-- PAGE CONTENT ENDS -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.page-content -->
    </div>
</div><!-- /.main-content -->
{/block}

{block name='footer'}
{include file='comm/footer'}
{/block}
{block name='script'}

<script src="__ace_js__/jquery-2.1.4.min.js"></script>

<!-- <![endif]-->
<!--[if IE]>
<script src="__ace_js__/jquery-1.11.3.min.js"></script>
<![endif]-->
<script type="text/javascript">
    if('ontouchstart' in document.documentElement) document.write("<script src='__ace_js__/jquery.mobile.custom.min.js'>"+"<"+"/script>");
</script>
<script src="__ace_js__/bootstrap.min.js"></script>

<!-- ace scripts -->
<script src="__ace_js__/ace-elements.min.js"></script>
<script src="__ace_js__/ace.min.js"></script>
<script src="__ace_js__/chosen.jquery.min.js"></script>
<script lang="javascript">
    $('#save_btn').click(function(){
        var classify = $('#classify').val();
        var worth = $('#worth').val();
        var weight_money = $('#weight_money').val();
        var remark = $('#remark').val();
        var status = $('#status').val();
        if(classify == ''){
            swal({
                type: 'warning', // 弹框类型
                title: '请输入物品种类', //标题
                confirmButtonColor: '#438EB9',// 确定按钮的 颜色
                confirmButtonText: '确定',// 确定按钮的 文字
            });
            return false;
        }
        if(worth == ''){
            swal({
                type: 'warning', // 弹框类型
                title: '请输入物品价值区间', //标题
                confirmButtonColor: '#438EB9',// 确定按钮的 颜色
                confirmButtonText: '确定',// 确定按钮的 文字
            });
            return false;
        }
        if(weight_money == ''){
            swal({
                type: 'warning', // 弹框类型
                title: '请输入单位重量价格', //标题
                confirmButtonColor: '#438EB9',// 确定按钮的 颜色
                confirmButtonText: '确定',// 确定按钮的 文字
            });
            return false;
        }
        $.ajax({
            url:"{:url('admin.article.add')}",
            type:'POST',
            dataType:'JSON',
            data:{'classify':classify,'worth':worth,'status':status,'weight_money':weight_money,'remark':remark},
            success:function(res){
                if(res.code == 1){
                    swal({
                        type: 'success', // 弹框类型
                        title: '操作成功', //标题
                        confirmButtonColor: '#438EB9',// 确定按钮的 颜色
                        confirmButtonText: '确定',// 确定按钮的 文字
                    }).then((isConfirm) => {
                        //判断 是否 点击的 确定按钮
                        if (isConfirm.value) {
                            location.href = "{:url('admin.article.index')}";
                        }
                    });
                }else{
                    swal({
                        type: 'warning', // 弹框类型
                        title:res.msg, //标题
                        confirmButtonColor: '#438EB9',// 确定按钮的 颜色
                        confirmButtonText: '确定',// 确定按钮的 文字
                    });
                }
                return false;
            },error:function(e){
                swal({
                    type: 'error', // 弹框类型
                    title:e.msg, //标题
                    confirmButtonColor: '#438EB9',// 确定按钮的 颜色
                    confirmButtonText: '确定',// 确定按钮的 文字
                });
            }
        })
    })


</script>
{/block}






